package studyStream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class MiddleWayStream {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list1, "徐瑞琪", "徐瑞琪", "徐瑞琪", "徐瑞琪", "徐添琪", "徐锦慧", "徐锦媛", "徐烨");
        Collections.addAll(list2, "徐瑞琪", "徐瑞琪", "徐瑞琪", "徐瑞琪", "徐添琪", "徐锦慧", "徐锦媛", "徐烨");
        //过滤
        list1.stream().filter(s -> s.startsWith("徐")).forEach(s -> System.out.println(s));
        System.out.println("=========================");
        //获取前4个
        list1.stream().limit(4).forEach(s -> System.out.println(s));
        System.out.println("=========================");
        //跳过前四个
        list1.stream().skip(4).forEach(s -> System.out.println(s));
        System.out.println("=========================");
        //去重复
        list1.stream().distinct().forEach(s -> System.out.println(s));
        System.out.println("=========================");
        //合并流
        Stream.concat(list1.stream(), list2.stream()).forEach(s -> System.out.println(s));
        System.out.println("=========================");
        //转换
        list1.stream().map(s -> new StringBuilder(s)).forEach(s -> System.out.println(s));


    }
}
